home *** CD-ROM | disk | FTP | other *** search
-
-
-
- library Tcl Command Language Library library
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- library - standard library of Tcl procedures
-
- SSYYNNOOPPSSIISS
- aauuttoo__eexxeeccookk _c_m_d |
- aauuttoo__llooaadd _c_m_d |
- aauuttoo__mmkkiinnddeexx _d_i_r _p_a_t_t_e_r_n |
- aauuttoo__rreesseett |
- ppaarrrraayy _a_r_r_a_y_N_a_m_e |
- uunnkknnoowwnn _c_m_d ?_a_r_g _a_r_g ...? |
-
- _________________________________________________________________ |
-
-
- IINNTTRROODDUUCCTTIIOONN |
- Tcl includes a library of Tcl procedures for commonly-needed |
- functions. The procedures defined in the Tcl library are |
- generic ones suitable for use by many different applica- |
- tions. The location of the Tcl library is returned by the |
- iinnffoo lliibbrraarryy command. In addition to the Tcl library, each |
- application will normally have its own library of support |
- procedures as well; the location of this library is nor- |
- mally given by the value of the $$aappppLLiibbrraarryy global variable. |
-
- To access the procedures in the Tcl library, an application |
- should source the file iinniitt..ttccll in the library, for example |
- with the Tcl command |
-
- ssoouurrccee [[iinnffoo lliibbrraarryy]]//iinniitt..ttccll |
- This will define the uunnkknnoowwnn procedure and arrange for the |
- other procedures to be loaded on-demand using the auto-load |
- mechanism defined below. |
-
-
- CCOOMMMMAANNDD PPRROOCCEEDDUURREESS |
- The following procedures are provided in the Tcl library: |
-
- aauuttoo__eexxeeccookk _c_m_d ||
- Determines whether there is an executable file by the |
- name _c_m_d. This command examines the directories in the |
- current search path (given by the PATH enviornment |
- variable) to see if there is an executable file named |
- _c_m_d in any of those directories. If so, it returns 1; |
- if not it returns 0. AAuuttoo__eexxeecc remembers information |
- about previous searches in an array named aauuttoo__eexxeeccss; |
- this avoids the path search in future calls for the |
- same _c_m_d. The command aauuttoo__rreesseett may be used to force |
- aauuttoo__eexxeeccookk to forget its cached information. |
-
- aauuttoo__llooaadd _c_m_d ||
- This command attempts to load the definition for a Tcl |
- procedure named _c_m_d. To do this, it searches an _a_u_t_o- |
-
-
-
- Sprite v.1.0 Printed: February 25, 1992 1
-
-
-
-
-
-
- library Tcl Command Language Library library
-
-
-
- _l_o_a_d _p_a_t_h, which is a list of one or more directories. |
- The auto-load path is given by the global variable |
- $$aauuttoo__ppaatthh if it exists. If there is no $$aauuttoo__ppaatthh |
- variable, then the TCLLIBPATH environment variable is |
- used, if it exists. Otherwise the auto-load path con- |
- sists of just the Tcl library directory. Within each |
- directory in the auto-load path there must be a file |
- ttccllIInnddeexx that describes the procedures defined in that |
- directory and the file in which each procedure is |
- defined. The ttccllIInnddeexx file should be generated with |
- the aauuttoo__mmkkiinnddeexx command. If _c_m_d is found in an index |
- file, then the appropriate script is ssoouurrcceed to create |
- the procedure. The aauuttoo__llooaadd command returns 1 if the |
- script was successfully sourced and _c_m_d now exists. |
- The command returns 0 if there was no index entry for |
- _c_m_d or if the script didn't actually define _c_m_d (e.g. |
- because index information is out of date). If an error |
- occurs while processing the script, then that error is |
- returned. AAuuttoo__llooaadd only reads the index information |
- once and saves it in the array aauuttoo__iinnddeexx; future |
- calls to aauuttoo__llooaadd check for _c_m_d in the array rather |
- than re-reading the index files. The cached index |
- information may be deleted with the command aauuttoo__rreesseett. |
- This will force the next aauuttoo__llooaadd command to reload |
- the index database from disk. |
-
- aauuttoo__mmkkiinnddeexx _d_i_r _p_a_t_t_e_r_n ||
- Generates an index suitable for use by aauuttoo__llooaadd. The |
- command searches _d_i_r for all files whose names match |
- _p_a_t_t_e_r_n (matching is done with the gglloobb command), gen- |
- erates an index of all the Tcl command procedures |
- defined in all the matching files, and stores the index |
- information in a file named ttccllIInnddeexx in _d_i_r. For exam- |
- ple, the command |
-
- aauuttoo__mmkkiinnddeexx ffoooo **..ttccll |
-
- will read all the ..ttccll files in subdirectory ffoooo and |
- generate a new index file ffoooo//ttccllIInnddeexx. |
-
- AAuuttoo__mmkkiinnddeexx parses the Tcl scripts in a relatively |
- unsophisticated way: if any line contains the word |
- pprroocc as its first characters then it is assumed to be a |
- procedure definition and the next word of the line is |
- taken as the procedure's name. Procedure definitions |
- that don't appear in this way (e.g. they have spaces |
- before the pprroocc) will not be indexed. |
-
- aauuttoo__rreesseett ||
- Destroys all the information cached by aauuttoo__eexxeeccookk and |
- aauuttoo__llooaadd. This information will be re-read from disk |
- the next time it is needed. |
-
-
-
- Sprite v.1.0 Printed: February 25, 1992 2
-
-
-
-
-
-
- library Tcl Command Language Library library
-
-
-
- ppaarrrraayy _a_r_r_a_y_N_a_m_e ||
- Prints on standard output the names and values of all |
- the elements in the array _a_r_r_a_y_N_a_m_e. AArrrraayyNNaammee must be |
- a global array. |
-
- uunnkknnoowwnn _c_m_d ?_a_r_g _a_r_g ...? ||
- This procedure is invoked automatically by the Tcl |
- interpreter whenever the name of a command doesn't |
- exist. The uunnkknnoowwnn procedure receives as its arguments |
- the name and arguments of the missing command. UUnnkknnoowwnn |
- first calls aauuttoo__llooaadd to load a procedure for the com- |
- mand. If this succeeds, then it executes the original |
- command with its original arguments. If the auto-load |
- fails then uunnkknnoowwnn calls aauuttoo__eexxeeccookk to see if there is |
- an executable file by the name _c_m_d. If so, it invokes |
- the Tcl eexxeecc command with _c_m_d and all the _a_r_g_s as argu- |
- ments. If _c_m_d can't be auto-executed, uunnkknnoowwnn checks |
- to see if _c_m_d is a unique abbreviation for an existing |
- Tcl command. If so, it expands the command name and |
- executes the command with the original arguments. |
- Finally, if none of the above efforts has been able to |
- execute the command, uunnkknnoowwnn generates an error return. |
- If the global variable aauuttoo__nnoollooaadd is defined, then the |
- auto-load step is skipped. If the global variable |
- aauuttoo__nnooeexxeecc is defined then the auto-exec step is |
- skipped. Under normal circumstances the return value |
- from uunnkknnoowwnn is the return value from the command that |
- was eventually executed. |
-
-
- VVAARRIIAABBLLEESS |
- The following global variables are defined or used by the |
- procedures in the Tcl library: |
-
- aauuttoo__eexxeeccss ||
- Used by aauuttoo__eexxeeccookk to record information about whether |
- particular commands exist as executable files. |
-
- aauuttoo__iinnddeexx ||
- Used by aauuttoo__llooaadd to save the index information read |
- from disk. |
-
- aauuttoo__nnooeexxeecc ||
- If set to any value, then uunnkknnoowwnn will not attempt to |
- auto-exec any commands. |
-
- aauuttoo__nnoollooaadd ||
- If set to any value, then uunnkknnoowwnn will not attempt to |
- auto-load any commands. |
-
- aauuttoo__ppaatthh ||
- If set, then it must contain a valid Tcl list giving |
-
-
-
- Sprite v.1.0 Printed: February 25, 1992 3
-
-
-
-
-
-
- library Tcl Command Language Library library
-
-
-
- directories to search during auto-load operations. |
-
- eennvv((TTCCLLLLIIBBPPAATTHH)) ||
- If set, then it must contain a valid Tcl list giving |
- directories to search during auto-load operations. |
- This variable is only used if aauuttoo__ppaatthh is not defined. |
-
- uunnkknnoowwnn__aaccttiivvee ||
- This variable is set by uunnkknnoowwnn to indicate that it is |
- active. It is used to detect errors where uunnkknnoowwnn |
- recurses on itself infinitely. The variable is unset |
- before uunnkknnoowwnn returns. |
-
-
- KKEEYYWWOORRDDSS |
- auto-exec, auto-load, library, unknown
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v.1.0 Printed: February 25, 1992 4
-
-
-
-